$(function () {
    query();
    staffquery();
    carquery();
    equipmentquery();
    repairquery();
    complainquery();

    var prefix = window.parent.document.location.href;
    var listData1;
    var status_infoS;
    var listData;
    var freeStatus;
    var waterFree;
    var dianFree;
    //查询业主列表
    function query() {
        //prefix = window.parent.document.location.href;
        debugger;
        listData1 = { pageVO: {currentPage: "1", pageSize: "15"}, userName: ""};
        listData = JSON.stringify(listData1);
        $.ajax({
            type: "post",
            url: "user/queryUserList",
            data: listData,
            contentType: "application/json;charset=utf-8", //这个是发送信息至服务器时内容编码类型
            dataType: "json",
            success: function (data) {
                console.log("业主信息：" + JSON.stringify(data));
                console.log(data.data.length);
                //获取后台传过来的jsonData,并进行解析
                var tableStr1;
                var len = data.data.length;

                for (var i = 0; i < len; i++) {
                    if (data.data[i].userHome.userHomeState == 0) {
                        homestatus = "未入住"
                    } else {
                        homestatus = "入住"
                    }
                    if ((data.data[i].userHome.userPropertyFee == 0)
                        || (data.data[i].userHome.userWaterFee == 0)
                        || (data.data[i].userHome.userElectricityFee == 0)
                        || (data.data[i].userHome.userAirFee == 0)) {
                        freeStatus = "欠费"
                    } else {
                        freeStatus = "已缴费"
                    }
                    tableStr1 = "<tr class='pos'><td class='username'>" + data.data[i].username + "</td>" + "<td>" + data.data[i].userHome.userHomes + "</td>" + "<td>" + homestatus + "</td>" + "<td>" + data.data[i].userHome.userPhone + "</td>" + "<td>" + freeStatus + "</td>" + "<td class='caozuoBox' style='text-align: center'><img src='static/assets/images/downShow.png'  style='width:20px'><div class='caozuo'>" +
                        "<span class='Info_Btn'>详情</span>" +
                        "<span class='userDel'>删除</span>" + "</div></td></tr>";
                    $(".ownerInfo_table .addUserList").append(tableStr1);
                }
                //将动态生成的table添加的事先隐藏的div中.
                // $(".adminName").text();
            }
        });
    }

    //查询员工列表
    function staffquery() {
        //prefix = window.parent.document.location.href;
        listData1 = { pageVO: {currentPage: "1", pageSize: "15"}, staffName: "", staffType: ""};
        listData = JSON.stringify(listData1);
        $.ajax({
            type: "post",
            url: "staff/getStaffList",
            data: listData,
            contentType: "application/json;charset=utf-8", //这个是发送信息至服务器时内容编码类型
            dataType: "json",
            success: function (data) {
                console.log("员工信息：" + JSON.stringify(data))
                console.log(data.data.length)
                //获取后台传过来的jsonData,并进行解析
                var tableStr2;
                var len = data.data.length;
                for (var i = 0; i < len; i++) {
                    if (data.data[i].workState == 0) {
                        data.data[i].workState = "在职"
                    } else {
                        data.data[i].workState = "离职"
                    }
                    tableStr2 = "<tr class='pos'><td>" + data.data[i].workerName + "</td>" + "<td>" + data.data[i].workSax + "</td>" + "<td>" + data.data[i].workPhone + "</td>" + "<td>" + data.data[i].workerType + "</td>" + "<td>" + data.data[i].workState + "</td>" + "<td class='workerId' style='display: none'>" + data.data[i].workerId + "</td>" + "<td class='caozuoBox' style='text-align: center'>" +
                        "<img src='static/assets/images/downShow.png'  style='width:20px'><div class='caozuo'><span class='staffInfo_Btn'>详情</span>" + "</div></td></tr>";
                    $(".staff_manage_table .addUserList").append(tableStr2);
                }
                //将动态生成的table添加的事先隐藏的div中.

            }
        });
    }

    //查询报修列表
    function repairquery() {
        //prefix = window.parent.document.location.href;
        //prefix = location.hostname+":"+location.port+"/"
        listData1 = { currentPage: "1", pagesize: "20", userName: ""}
        $.ajax({
            type: "post",
            url: "userGuarantee/selectUserGuaranteeList",
            data: listData1,
            dataType: "json",
            success: function (data) {
                console.log("报修列表：" + JSON.stringify(data))
                console.log(data.data.length)
                //获取后台传过来的jsonData,并进行解析
                var tableStr;
                var len = data.data.length;
                for (var i = 0; i < len; i++) {
                    if (data.data[i].guaranteeState == 0) {
                        data.data[i].guaranteeState = "未处理"
                        tableStr = "<tr class='pos'><td class='guarantee_id'>" + data.data[i].guarantee_id + "</td>" + "<td>" + data.data[i].guaranteeDesc + "</td>" +
                            "<td class='baoxiu'>" + data.data[i].userName + "</td>" + "<td>" + data.data[i].guaranteeState + "</td>" +
                            "<td class='caozuoBox' style='text-align: center'><img src='static/assets/images/downShow.png'  style='width:20px'><div class='caozuo'><span class='updateRepair'>处理</span><span class='repairDel'>删除</span>" + "</div></td></tr>";
                    } else {
                        data.data[i].guaranteeState = "已处理"
                        tableStr = "<tr class='pos'><td class='guarantee_id'>" + data.data[i].guarantee_id + "</td>" + "<td>" + data.data[i].guaranteeDesc + "</td>" +
                            "<td class='baoxiu'>" + data.data[i].userName + "</td>" + "<td>" + data.data[i].guaranteeState + "</td>" +
                            "<td class='caozuoBox' style='text-align: center'><img src='static/assets/images/downShow.png'  style='width:20px'><div class='caozuo'><span class='repairDel'>删除</span>" + "</div></td></tr>";
                    }
                    $(".repair_table .addUserList").append(tableStr);
                }
                //将动态生成的table添加的事先隐藏的div中.

            },
            error: function () {
                //alert("获取报修列表失败！")
            }
        });
    }

    //删除报修
    $("body").on("click", ".repairDel", function (event) {
        $(this).parents(".pos").css("display", "none");
        $(".caozuo").fadeOut();
        event.stopPropagation();
        var guarantee_id = $(this).parents(".pos").find(".guarantee_id").text();
        debugger;
        var guarantee = {guarantee_id: guarantee_id};
        $.ajax({
            type: "post",
            url: "userGuarantee/deleteUserGuarantee",
            data: guarantee,
            dataType: "json",
            success: function (data) {
                console.log(this);
                alert("删除成功");
            },
            error: function (data) {
                console.log(JSON.stringify(data));
                console.log(data);
                alert("删除失败")
            }

        });
    });

    //查询车位列表
    function carquery() {
        prefix = window.parent.document.location.href;
        listData1 = { pageVO: {currentPage: "1", pageSize: "15"}, userCarName: ""}
        listData = JSON.stringify(listData1);
        $.ajax({
            type: "post",
            url: "car/getUserCarList",
            data: listData,
            contentType: "application/json;charset=utf-8", //这个是发送信息至服务器时内容编码类型
            dataType: "json",
            success: function (data) {
                console.log("停车列表：" + JSON.stringify(data))
                console.log(data.data.length)
                //获取后台传过来的jsonData,并进行解析
                var tableStr;
                var len = data.data.length;
                for (var i = 0; i < len; i++) {
                    tableStr = "<tr class='pos'><td class='carId' style='display: none'>" + data.data[i].userCarId + "</td>" + "<td>" + data.data[i].userRelName + "</td>" + "<td>" + data.data[i].userCard + "</td>" + "<td>" + data.data[i].userPhone + "</td>" + "<td>" + data.data[i].usercarCard + "</td>" + "<td>" + data.data[i].carParkName + "</td>" + "<td class='caozuoBox' style='text-align: center'><img src='static/assets/images/downShow.png'  style='width:20px'>" +
                        "<div class='caozuo'>" +
                        "<span class='CarInfo_Btn'>详情</span>" +
                        "<span class='carDelete'>删除</span>" + "</div></td></tr>";
                    $(".parkInfo_table .addUserList").append(tableStr);
                }
                //将动态生成的table添加的事先隐藏的div中.

            }
        });
    }

    //查询设备列表
    function equipmentquery() {
        debugger;
        prefix = window.parent.document.location.href;
        listData1 = {currentPage: "1", pagesize: "20"};
        // listData = JSON.stringify(listData1);

        $.ajax({
            type: "post",
            url: "userEquipment/selectUserEquipmentList",
            data: listData1,
            // contentType: "application/json;charset=utf-8", //这个是发送信息至服务器时内容编码类型
            dataType: "json",
            success: function (data) {

                console.log("设备列表：" + JSON.stringify(data));
                //获取后台传过来的jsonData,并进行解析
                var tableStr;
                var len = data.data.length;
                for (var i = 0; i < len; i++) {
                    if (data.data[i].equipmentState == 0) {
                        data.data[i].equipmentState = "正常"
                        tableStr = "<tr class='pos'><td class='equipmentId' style='display: none'>" + data.data[i].equipmentId + "</td>" + "<td>" + data.data[i].equipmentName + "</td>" + "<td>" + data.data[i].equipmentType + "</td>" + "<td>" + data.data[i].equipmentDesc + "</td>" + "<td>" + data.data[i].equipmentState + "</td>" +
                            "<td class='caozuoBox' style='text-align: center'><img src='static/assets/images/downShow.png'  style='width:20px'><div class='caozuo'><span class='equipmentDel'>删除</span>" + "</div></td></tr>";
                    } else {
                        data.data[i].equipmentState = "损坏"
                        tableStr = "<tr class='pos'><td class='equipmentId' style='display: none'>" + data.data[i].equipmentId + "</td>" + "<td>" + data.data[i].equipmentName + "</td>" + "<td>" + data.data[i].equipmentType + "</td>" + "<td>" + data.data[i].equipmentDesc + "</td>" + "<td>" + data.data[i].equipmentState + "</td>" +
                            "<td class='caozuoBox' style='text-align: center'><img src='static/assets/images/downShow.png'  style='width:20px'><div class='caozuo'><span class='equipmentUpdate'>修理</span><span class='equipmentDel'>删除</span>" + "</div></td></tr>";
                    }

                    $(".equipment_table .addUserList").append(tableStr);
                }
                //将动态生成的table添加的事先隐藏的div中.

            }
        });
    }

    $("body").on("click", ".equipmentDel", function (event) {
        $(this).parents(".pos").css("display", "none");
        $(".caozuo").fadeOut();
        event.stopPropagation();
        var equipmentId = $(this).parents(".pos").find(".equipmentId").text();
        debugger;
        var equipment = {equipmentId: equipmentId};
        $.ajax({
            type: "post",
            url: "userEquipment/deleteUserEquipment",
            data: equipment,
            dataType: "json",
            success: function (data) {
                console.log(this);
                alert("删除成功");
            },
            error: function (data) {
                console.log(JSON.stringify(data));
                console.log(data);
                alert("删除失败")
            }

        });
    });
    //查询投诉列表
    function complainquery() {
        prefix = window.parent.document.location.href;
        ;
        listData1 = {currentPage: "1", pagesize: "20", userName: ""};
        debugger;
        $.ajax({
            type: "post",
            url: "userComplaint/selectUserComplaintList",
            data: listData1,
            dataType: "json",
            success: function (data) {
                debugger;
                console.log("投诉列表：" + JSON.stringify(data));
                //获取后台传过来的jsonData,并进行解析
                debugger;
                var tableStr3;
                var complainstr;
                var len = data.data.length;
                for (var i = 0; i < len; i++) {
                    debugger;
                    if (data.data[i].complaintState == 0) {
                        complainstr = "未处理"
                        tableStr3 = "<tr class='pos'><td class='complaintId'>" + data.data[i].complaintId + "</td>" + "<td>" + data.data[i].complaintType + "</td>" + "<td class='tousuname'>" + data.data[i].userName + "</td>" + "<td>" + data.data[i].complaintDesc + "</td>"
                            + "<td>" + complainstr + "</td>" + "<td class='caozuoBox' style='text-align: center'><img src='static/assets/images/downShow.png'  style='width:20px'><div class='caozuo'><span class='complaintUpdate'>处理</span><span class='complaintDel'>删除</span>" + "</div></td></tr>";
                    } else {
                        complainstr = "已处理"
                        tableStr3 = "<tr class='pos'><td class='complaintId'>" + data.data[i].complaintId + "</td>" + "<td>" + data.data[i].complaintType + "</td>" + "<td class='tousuname'>" + data.data[i].userName + "</td>" + "<td>" + data.data[i].complaintDesc + "</td>"
                            + "<td>" + complainstr + "</td>" + "<td class='caozuoBox' style='text-align: center'><img src='static/assets/images/downShow.png'  style='width:20px'><div class='caozuo'><span class='complaintDel'>删除</span>" + "</div></td></tr>";
                    }
                    $(".complain_table .addUserList").append(tableStr3);
                }
                //将动态生成的table添加的事先隐藏的div中.

            }
        });
    }

    //删除投诉
    $("body").on("click", ".complaintDel", function (event) {
        $(this).parents(".pos").css("display", "none");
        $(".caozuo").fadeOut();
        event.stopPropagation();
        var complaintId = $(this).parents(".pos").find(".complaintId").text();
        debugger;
        var complaint = {complaintId: complaintId};
        $.ajax({
            type: "post",
            url: "userComplaint/deleteUserComplaint",
            data: complaint,
            dataType: "json",
            success: function (data) {
                console.log(this);
                alert("删除成功");
            },
            error: function (data) {
                console.log(JSON.stringify(data));
                console.log(data);
                alert("删除失败")
            }

        });
    });

    //右侧操作弹框
    $("body").on("click", ".caozuoBox", function () {
        $(this).children(".caozuo").toggle("showHid");
    });

    //业主详情弹框
    $("body").on("click", ".Info_Btn", function (event) {
        event.stopPropagation();
        $(".caozuo").fadeOut();
        debugger;
        debugger;
        var username = $(this).parents(".pos").find(".username").text();
        var userinfo1 = {userName: username};
        var userinfo = JSON.stringify(userinfo1);
        $.ajax({
            type: "post",
            url: "user/getUserHomeDetail",
            data: userinfo,
            contentType: "application/json;charset=utf-8", //这个是发送信息至服务器时内容编码类型
            dataType: "json",
            success: function (data) {
                console.log("用户详情：" + JSON.stringify(data));
                $(".userInfo_show").fadeIn();
                $(".user_name").show();
                $(".user_rel_name").show();
                $(".user_card").show();
                $(".user_phone").show();
                $(".user_homes").show();
                $(".user_home_state").show();
                $(".user_electricity_fee").show();
                $(".user_property_fee").show();
                $(".user_water_fee").show();
                $(".user_air_fee").show();
                $(".user_home_description").show();

                $(".user_name span").text("用户名：");
                $(".inp11").val(data.data.userName);
                $(".user_rel_name span").text("真实姓名：");
                $(".inp12").val(data.data.userRelName)
                $(".user_card span").text("身份证号：");
                $(".inp13").val(data.data.userCard);
                $(".user_phone span").text("联系方式：");
                $(".inp14").val(data.data.userPhone);
                $(".user_homes span").text("业主房产：");
                $(".inp15").val(data.data.userHomes);
                $(".user_home_state span").text("入住状态：");
                $("input:radio[name='user_home_state'][value=" + data.data.userHomeState + "]").attr('checked', 'true');
                $(".user_electricity_fee span").text("电费情况：");
                $("input:radio[name='user_electricity_fee'][value=" + data.data.userElectricityFee + "]").attr('checked', 'true');
                $(".user_property_fee span").text("物业缴费：");
                $("input:radio[name='user_property_fee'][value=" + data.data.userPropertyFee + "]").attr('checked', 'true');
                $(".user_water_fee span").text("水费情况：");
                $("input:radio[name='user_water_fee'][value=" + data.data.userWaterFee + "]").attr('checked', 'true');
                $(".user_air_fee span").text("燃气缴费：");
                $("input:radio[name='user_air_fee'][value=" + data.data.userAirFee + "]").attr('checked', 'true');
                $(".user_home_description span").text("房产描述：");
                $(".inp111").val(data.data.userHomeDescription);
                $(".updateInfoBtn").addClass("ownerInfoUpdata");
            }
        });
    });

    //员工详情弹框
    $("body").on("click", ".staffInfo_Btn", function (event) {
        event.stopPropagation();
        $(".caozuo").fadeOut();
        var workerId = $(this).parents(".pos").find(".workerId").text();
        debugger;
        var staffinfo1 = {workerId: workerId};
        var staffinfo = JSON.stringify(staffinfo1);
        $.ajax({
            type: "post",
            url: "staff/getStaffDetail",
            data: staffinfo,
            contentType: "application/json;charset=utf-8", //这个是发送信息至服务器时内容编码类型
            dataType: "json",
            success: function (data) {
                console.log("员工详情：" + JSON.stringify(data))
                if (data.data.workState == 0) {
                    homestatus = "在职"
                } else {
                    homestatus = "离职"
                }
                $(".homeNu_infoS").show();
                $(".phone_infoS").show();
                $(".homeStatus_infoS").show();
                $(".waterFree_infoS").show();
                $(".sax_infoS").show();
                $(".status_infoS").show();
                $(".userInfo_show").fadeIn();
                $(".name_infoS span").text("员工ID：");
                $(".inp1").val(data.data.workerId)
                $(".homeNu_infoS span").text("员工姓名：");
                $(".inp2").val(data.data.workerName)
                $(".phone_infoS span").text("员工手机号：");
                $(".inp3").val(data.data.workPhone)
                $(".homeStatus_infoS span").text("员工类型：");
                $(".inp4").val(data.data.workerType)
                $(".sax_infoS span").text("员工性别：");
                $("input:radio[name='sax'][value=" + data.data.workSax + "]").attr('checked', 'true');
                $(".waterFree_infoS span").text("员工薪资：");
                $(".inp6").val(data.data.workerSalary)
                $(".status_infoS span").text("在职状态：");
                $("input:radio[name='status'][value=" + data.data.workState + "]").attr('checked', 'true');
                $(".updateInfoBtn").addClass("staffInfoUpdate");
            }
        });
    });

    //停车详情弹框
    $("body").on("click", ".CarInfo_Btn", function (event) {
        event.stopPropagation();
        $(".caozuo").fadeOut();
        var userCarId = $(this).parents(".pos").find(".carId").text();
        var userCar1 = {userCarId: userCarId};
        var userCar = JSON.stringify(userCar1);
        debugger;
        $.ajax({
            type: "post",
            url: "car/getCarDetail",
            data: userCar,
            contentType: "application/json;charset=utf-8", //这个是发送信息至服务器时内容编码类型
            dataType: "json",
            success: function (data) {
                console.log("停车详情：" + JSON.stringify(data))

                $(".userInfo_show").fadeIn();
                $(".userRelName").show();
                $(".userCard").show();
                $(".userPhone").show();
                $(".usercarCard").show();
                $(".carParkName").show();

                $(".userCarId span").text("车位ID：");
                $(".inp21").val(data.data.userCarId);
                $(".userRelName span").text("用户名：");
                $(".inp22").val(data.data.userRelName)
                $(".userCard span").text("身份证号：");
                $(".inp23").val(data.data.userCard);
                $(".userPhone span").text("联系方式：");
                $(".inp24").val(data.data.userPhone);
                $(".usercarCard span").text("车牌号码：");
                $(".inp25").val(data.data.usercarCard);
                $(".carParkName span").text("车位名称：");
                $(".inp26").val(data.data.carParkName);
                $(".updateInfoBtn").addClass("carParkUpdate");
            }
        });
    });

    //设备详情弹框
    $("body").on("click", ".equipmentInfo_Btn", function (event) {
        event.stopPropagation();
        $(".caozuo").fadeOut();
        var staffinfo1 = {currentPage: "1", pagesize: "20"};
        // var staffinfo = JSON.stringify(staffinfo1);
        $.ajax({
            type: "post",
            url: "userEquipment/selectUserEquipmentList",
            data: staffinfo1,
            // contentType: "application/json;charset=utf-8", //这个是发送信息至服务器时内容编码类型
            dataType: "json",
            success: function (data) {
                console.log("设备详情：" + JSON.stringify(data))
                if (data.complaintState == 0) {
                    homestatus = "好"
                } else {
                    homestatus = "坏"
                }
                $(".propertyFree_infoS").show();
                $(".waterFree_infoS").show();
                $(".userInfo_show").fadeIn();
                $(".name_infoS span").text("设备ID：");
                $(".inp1").val(data.data.equipmentId);
                $(".homeNu_infoS span").text("设备名称：");
                $(".inp2").val(data.data.equipmentName);
                $(".phone_infoS span").text("设备类型：");
                $(".inp3").val(data.data.equipmentType);
                $(".homeStatus_infoS span").text("设备描述：");
                $(".inp4").val(data.data.equipmentDesc);
                $(".propertyFree_infoS span").text("设备位置：");
                $(".inp5").val(data.data.equipmentLocation);
                $(".waterFree_infoS span").text("设备状态：");
                $(".inp6").val(homestatus);
                $(".updataInfoBtn").addClass(".equipmentInfoUpdata")
            }
        });
    });

    /*//投诉详情弹框
     $("body").on("click", ".Complaint_Btn", function (event) {
     var text = $(this).parents(".pos").find(".tousuname").text();
     console.log("投诉用户名：" + text)
     event.stopPropagation();
     $(".caozuo").fadeOut();
     var staffinfo1 = {currentPage: "1", pagesize: "20", userName: text};
     // var staffinfo = JSON.stringify(staffinfo1);
     $.ajax({
     type: "post",
     url: prefix + "userComplaint/selectUserComplaintList",
     data: staffinfo1,
     // contentType: "application/json;charset=utf-8", //这个是发送信息至服务器时内容编码类型
     dataType: "json",
     success: function (data) {
     console.log("投诉详情：" + JSON.stringify(data))
     if (data.equipmentState == 0) {
     homestatus = "未处理"
     } else {
     homestatus = "已处理"
     }
     $(".propertyFree_infoS").show();
     $(".waterFree_infoS").show();
     $(".userInfo_show").fadeIn();
     $(".name_infoS span").text("投诉记录ID：");
     $(".inp1").val(data.data.complaintId);
     $(".homeNu_infoS span").text("投诉类别：");
     $(".inp2").val(data.data.complaintType);
     $(".phone_infoS span").text("投诉用户名：");
     $(".inp3").val(data.data.userName);
     $(".homeStatus_infoS span").text("投诉描述：");
     $(".inp4").val(data.data.complaintDesc);
     $(".propertyFree_infoS span").text("投诉状态：");
     $(".inp5").val(homestatus);
     $(".waterFree_infoS span").text("时间：");
     $(".inp6").val(data.data.complaintDate);
     $(".updataInfoBtn").addClass(".complaintInfoUpdata")
     }
     });
     });*/

    //报修详情弹框
    /*$("body").on("click", ".repairInfo_Btn", function (event) {
     var text = $(this).parents(".pos").find(".baoxiu").text();
     console.log("报修人：" + text)
     event.stopPropagation();
     $(".caozuo").fadeOut();
     var staffinfo1 = {currentPage: "1", pagesize: "20", userName: text};
     // var staffinfo = JSON.stringify(staffinfo1);
     $.ajax({
     type: "post",
     url: prefix + "userGuarantee/selectUserGuaranteeList",
     data: staffinfo1,
     // contentType: "application/json;charset=utf-8", //这个是发送信息至服务器时内容编码类型
     dataType: "json",
     success: function (data) {
     console.log("报修详情：" + JSON.stringify(data))
     if (data.equipmentState == 0) {
     homestatus = "未处理"
     } else {
     homestatus = "已处理"
     }

     $(".userInfo_show").fadeIn();
     $(".name_infoS span").text("投诉记录ID：");
     $(".inp1").val(data.data.complaintId);
     $(".homeNu_infoS span").text("投诉类别：");
     $(".inp2").val(data.data.complaintType);
     $(".phone_infoS span").text("投诉用户名：");
     $(".inp3").val(data.data.userName);
     $(".homeStatus_infoS span").text("投诉描述：");
     $(".inp4").val(data.data.complaintDesc);
     $(".updataInfoBtn").addClass(".repairInfoUpdata")
     }
     });
     });
     */
    //业主停用
    // $("body").on("click",".userStop",function (event) {
    //     event.stopPropagation();
    //     $(".caozuo").fadeOut();
    //     var userStop1 = {userName:"12345",userState:"1"};
    //     var userStop = JSON.stringify(userStop1);
    //     $.ajax({
    //         type: "post",
    //         url:  prefix +"/managesystem/user/updateUser",
    //         data: userStop,
    //         contentType: "application/json;charset=utf-8", //这个是发送信息至服务器时内容编码类型
    //         dataType:"json",
    //         success:function (data) {
    //             console.log(JSON.stringify(data));
    //             console.log(data);
    //             if($(".userStop").text() == "停用停用停用停用停用"){
    //                 console.log($(".userStop").text())
    //                 $(".userStop").text("启用");
    //                 alert("停用用户成功")
    //             }else{
    //                 console.log($(".userStop").text())
    //                 $(".userStop").text("停用");
    //                 alert("启用用户成功")
    //             }
    //         },
    //         error:function (data) {
    //             alert("操作失败！")
    //         }
    //     });
    // });

    //员工更新
    $("body").on("click", ".staffInfoUpdate", function (event) {
        event.stopPropagation();
        $(".caozuo").fadeOut();
        debugger;
        var workerId = $(".inp1").val();
        var workerName = $(".inp2").val();
        var workerSalary = $(".inp6").val();
        var workerType = $(".inp4").val();
        var workSax = $('input[name="sax"]:checked').val();
        var workPhone = $(".inp3").val();
        var workState = $('input[name="status"]:checked').val();

        var staffUpdata1 = {
            workerId: workerId,
            workerName: workerName,
            workerSalary: workerSalary,
            workerType: workerType,
            workSax: workSax,
            workPhone: workPhone,
            workState: workState
        };
        var staffUpdata = JSON.stringify(staffUpdata1);
        $.ajax({
            type: "post",
            url: "staff/updateStaff",
            data: staffUpdata,
            contentType: "application/json;charset=utf-8", //这个是发送信息至服务器时内容编码类型
            dataType: "json",
            success: function (data) {
                console.log(JSON.stringify(data));
                console.log(data);
                alert("更新员工成功")
            },
            error: function (data) {
                alert("操作失败！")
            }
        });
    });

    //业主更新
    $("body").on("click", ".ownerInfoUpdata", function (event) {
        event.stopPropagation();
        $(".caozuo").fadeOut();

        var userName = $(".inp11").val();
        var userRelName = $(".inp12").val();
        var userCard = $(".inp13").val();
        var userPhone = $(".inp14").val();
        var userHomes = $(".inp15").val();
        var userHomeState = $('input[name="user_home_state"]:checked').val();
        // var userHomeState = $(".inp16").val();
        var userElectricityFee = $('input[name="user_electricity_fee"]:checked').val();
        var userPropertyFee = $('input[name="user_property_fee"]:checked').val();
        var userWaterFee = $('input[name="user_water_fee"]:checked').val();
        var userAirFee = $('input[name="user_air_fee"]:checked').val();
        var userHomeDescription = $(".inp111").val();
        var owner1 = {
            userName: userName,
            userRelName: userRelName,
            userCard: userCard,
            userPhone: userPhone,
            userHomes: userHomes,
            userHomeState: userHomeState,
            userElectricityFee: userElectricityFee,
            userPropertyFee: userPropertyFee,
            userWaterFee: userWaterFee,
            userAirFee: userAirFee,
            userHomeDescription: userHomeDescription
        };
        var staffUpdata = JSON.stringify(owner1);
        debugger;
        $.ajax({
            type: "post",
            url: "user/updateUserHome",
            data: staffUpdata,
            contentType: "application/json;charset=utf-8", //这个是发送信息至服务器时内容编码类型
            dataType: "json",
            success: function (data) {
                console.log(JSON.stringify(data));
                console.log(data);
                alert("更新业主成功")
            },
            error: function (data) {
                alert("操作失败！")
            }
        });
    });

    //报修更新
    $("body").on("click", ".updateRepair", function (event) {
        event.stopPropagation();
        $(".caozuo").fadeOut();
        var guarantee_id = $(this).parents(".pos").find(".guarantee_id").text();
        var repairUpdata = {
            guarantee_id: guarantee_id, guaranteeState: "1"
        };
        $.ajax({
            type: "post",
            url: "userGuarantee/updateUserGuarantee",
            data: repairUpdata,
            dataType: "json",
            success: function (data) {
                console.log(JSON.stringify(data));
                console.log(data);
                alert("更新报修成功")
            },
            error: function (data) {
                alert("操作失败！")
            }
        });
    });

    //设备更新
    $("body").on("click", ".equipmentUpdate", function (event) {
        event.stopPropagation();
        $(".caozuo").fadeOut();
        var equipmentId = $(this).parents(".pos").find(".equipmentId").text();
        var equipment = {
            equipmentId: equipmentId, equipmentState: "0"
        };
        $.ajax({
            type: "post",
            url: "userEquipment/updateUserEquipment",
            data: equipment,
            // contentType: "application/json;charset=utf-8", //这个是发送信息至服务器时内容编码类型
            dataType: "json",
            success: function (data) {
                console.log(JSON.stringify(data));
                console.log(data);
                alert("更新成功")
            },
            error: function (data) {
                alert("操作失败！")
            }
        });
    });

    //投诉更新
    $("body").on("click", ".complaintUpdate", function (event) {
        event.stopPropagation();
        $(".caozuo").fadeOut();
        var complaintId = $(this).parents(".pos").find(".complaintId").text();
        var complaintUpdata1 = {
            complaintId: complaintId, complaintState: "1"
        };
        debugger;
        $.ajax({
            type: "post",
            url: "userComplaint/updateUserComplaint",
            data: complaintUpdata1,
            dataType: "json",
            success: function (data) {
                console.log(JSON.stringify(data));
                console.log(data);
                alert("更新投诉成功")
            },
            error: function (data) {
                alert("操作失败！")
            }
        });
    });

    //停车更新
    $("body").on("click", ".carParkUpdate", function (event) {
        event.stopPropagation();
        $(".caozuo").fadeOut();
        var userCarId = $(".inp21").val();
        var userRelName = $(".inp22").val();
        var userCard = $(".inp23").val();
        var userPhone = $(".inp24").val();
        var usercarCard = $(".inp25").val();
        var carParkName = $(".inp26").val();

        var carUpdata1 = {
            userCarId: userCarId,
            userRelName: userRelName,
            userCard: userCard,
            userPhone: userPhone,
            usercarCard: usercarCard,
            carParkName: carParkName
        };
        var carUpdata = JSON.stringify(carUpdata1);
        $.ajax({
            type: "post",
            url: "car/updateCar",
            data: carUpdata,
            contentType: "application/json;charset=utf-8", //这个是发送信息至服务器时内容编码类型
            dataType: "json",
            success: function (data) {
                console.log(JSON.stringify(data));
                console.log(data);
                alert("更新成功")
            },
            error: function (data) {
                alert("操作失败！")
            }
        });
    });

    //删除业主
    $("body").on("click", ".userDel", function (event) {
        $(this).parents(".pos").css("display", "none");
        $(".caozuo").fadeOut();
        event.stopPropagation();
        var username = $(this).parents(".pos").find(".username").text();
        debugger;
        var userDel1 = {userName: username};
        var userDel = JSON.stringify(userDel1);
        $.ajax({
            type: "post",
            url: "user/deleteUser",
            data: userDel,
            contentType: "application/json;charset=utf-8", //这个是发送信息至服务器时内容编码类型
            dataType: "json",
            success: function (data) {
                console.log(this);
                alert("删除成功");
            },
            error: function (data) {
                console.log(JSON.stringify(data));
                console.log(data);
                alert("删除失败")
            }

        });
    });

    //删除员工
    $("body").on("click", ".userDel", function (event) {
        $(this).parents(".pos").css("display", "none");
        $(".caozuo").fadeOut();
        event.stopPropagation();
        var userDel1 = {userName: ""};
        var userDel = JSON.stringify(userDel1);
        $.ajax({
            type: "post",
            url: "user/deleteUser",
            data: userDel,
            contentType: "application/json;charset=utf-8", //这个是发送信息至服务器时内容编码类型
            dataType: "json",
            success: function (data) {
                console.log(this);
                alert("删除成功");
            },
            error: function (data) {
                console.log(JSON.stringify(data));
                console.log(data);
                alert("删除失败")
            }

        });
    });
    //删除车位
    $("body").on("click", ".carDelete", function (event) {
        $(this).parents(".pos").css("display", "none");
        $(".caozuo").fadeOut();
        event.stopPropagation();
        debugger;
        var userCarId = $(this).parents(".pos").find(".carId").text();
        var carDel1 = {userCarId: userCarId};
        var carDel = JSON.stringify(carDel1);
        $.ajax({
            type: "post",
            url: "car/deleteCar",
            data: carDel,
            contentType: "application/json;charset=utf-8", //这个是发送信息至服务器时内容编码类型
            dataType: "json",
            success: function (data) {
                console.log(this);
                alert("删除成功");
            },
            error: function (data) {
                console.log(JSON.stringify(data));
                console.log(data);
                alert("删除失败")
            }
        });
    });
    /**
     * 定位当前城市
     */
    function locationInit() {
        $.getScript('http://int.dpool.sina.com.cn/iplookup/iplookup.php?format=js', function (_result) {
            if (remote_ip_info.ret == '1') {
                cityName = remote_ip_info.city;
                console.log(cityName);
                $(".city_Name").html(cityName)
            }
        });
    }

    locationInit();
    // $.ajax({
    //     type: "post",
    //     url: url,
    //     data: {
    //         username:userName,
    //         password:keyWord
    //     },
    //     dataType:"json",
    //     success:function () {
    //         $(".user_Name")
    //     }
    // })

    //新增业主
    $(".ownerInfo_table .add_User").click(function () {
        $(".add_Inp_box").show();
    });
    $(".ownerInfo_table .noAdd_Btn").click(function () {
        $(".add_Inp_box").hide();
    });

    //新增员工
    $(".staff_manage_table .add_User").click(function () {
        $(".add_Inp_box").show();
    });
    $(".staff_manage_table .noAdd_Btn").click(function () {
        $(".add_Inp_box").hide();
    });

    //新增停车
    $(".parkInfo_table .add_User").click(function () {
        $(".add_Inp_box").show();
    });
    $(".parkInfo_table .noAdd_Btn").click(function () {
        $(".add_Inp_box").hide();
    });

    //保修插入
    $(".repair_table .add_User").click(function () {
        $(".add_Inp_box").show();
    });
    $(".repair_table .noAdd_Btn").click(function () {
        $(".add_Inp_box").hide();
    });

    //投诉插入
    $(".complain_table .add_User").click(function () {
        $(".add_Inp_box").show();
    });
    $(".complain_table .noAdd_Btn").click(function () {
        $(".add_Inp_box").hide();
    });

    //设备插入
    $(".equipment_table .add_User").click(function () {
        $(".add_Inp_box").show();
    });
    $(".equipment_table .noAdd_Btn").click(function () {
        $(".add_Inp_box").hide();
    });
    // var add_UserName;
    // var add_UserKey;
    var addData1;
    var addData;

    //新增业主
    $(".ownerInfo_table .add_Btn").click(function () {
        // add_UserName =  $(".add_UserName").val();
        // add_UserKey = $(".add_UserKey").val();
        var userName = $(".userName").val();
        var password = $(".userPassword").val();
        addData1 = {userName: userName, password: password};
        addData = JSON.stringify(addData1);
        $.ajax({
            type: "post",
            url: "user/addUser",
            data: addData,
            contentType: "application/json;charset=utf-8", //这个是发送信息至服务器时内容编码类型
            dataType: "json",
            success: function (data) {
                console.log(JSON.stringify(data));
                if (data.statue == true) {
                    query();
                    alert("新增成功！")
                } else {
                    alert(data.msg)
                }

            }
        })
    });

    //新增员工
    $(".staff_manage_table .add_Btn").click(function () {

        var workerName = $(".workerName").val();
        var workerSalary = $(".workerSalary").val();
        var workerType = $(".workerType").val();
        var workSax = $(".workSax").val();
        var workPhone = $(".workPhone").val();
        var workState = $(".workState").val();
        addData1 = {
            workerName: workerName,
            workerSalary: workerSalary,
            workerType: workerType,
            workSax: workSax,
            workPhone: workPhone,
            workState: workState
        };
        addData = JSON.stringify(addData1);
        $.ajax({
            type: "post",
            url: "staff/addStaff",
            data: addData,
            contentType: "application/json;charset=utf-8", //这个是发送信息至服务器时内容编码类型
            dataType: "json",
            success: function (data) {
                console.log(JSON.stringify(data));
                if (data.statue == true) {
                    staffquery();
                    alert("新增成功！")
                } else {
                    alert(data.msg)
                }

            }
        })
    });

    //插入投诉
    $(".complain_table .add_Btn").click(function () {
        // add_UserName =  $(".add_UserName").val();
        // add_UserKey = $(".add_UserKey").val();
        addData1 = {
            complaintType: "cxvdfbcvb",
            userName: "",
            complaintDesc: "",
            complaintState: "0"
        };
        addData = JSON.stringify(addData1);
        $.ajax({
            type: "post",
            url: "userComplaint/insertUserGuarantee",
            data: addData,
            contentType: "application/json;charset=utf-8", //这个是发送信息至服务器时内容编码类型
            dataType: "json",
            success: function (data) {
                console.log(JSON.stringify(data));
                if (data.statue == true) {
                    carquery();
                    alert("新增成功！")
                } else {
                    alert(data.msg)
                }

            }
        })
    });

    //插入设备
    $(".equipment_table .add_Btn").click(function () {
        debugger;
        var equipmentName = $(".equipmentName").val();
        var equipmentDesc = $(".equipmentDesc").val();
        var equipmentState = $('input[name="equipmentState"]:checked').val();;
        var equipmentType = $(".equipmentType").val();
        var equipmentLocation = $(".equipmentLocation").val();
        addData1 = {
            equipmentName: equipmentName,
            equipmentDesc: equipmentDesc,
            equipmentState: equipmentState,
            equipmentType: equipmentType,
            equipmentLocation: equipmentLocation
        };
        //addData = JSON.stringify(addData1);
        $.ajax({
            type: "post",
            url: "userEquipment/insertUserEquipment",
            data: addData1,
            //contentType: "application/json;charset=utf-8", //这个是发送信息至服务器时内容编码类型
            dataType: "json",
            success: function (data) {
                console.log(JSON.stringify(data));
                if (data.statue == true) {
                    carquery();
                    alert("新增成功！")
                } else {
                    alert(data.msg)
                }

            }
        })
    });


    //新增停车
    $(".parkInfo_table .add_Btn").click(function () {
        // add_UserName =  $(".add_UserName").val();
        // add_UserKey = $(".add_UserKey").val();
        var userRealName = $(".userRealName").val();
        var userCard = $(".userCard").val();
        var userCarCard = $(".userCarCard").val();
        var carParkName = $(".carParkName").val();
        var userPhone = $(".userPhone").val();
        addData1 = {
            userRelName: userRealName,
            userCard: userCard,
            userPhone: userPhone,
            usercarCard: userCarCard,
            carParkName: carParkName
        };
        addData = JSON.stringify(addData1);
        $.ajax({
            type: "post",
            url: "car/addUserCar",
            data: addData,
            contentType: "application/json;charset=utf-8", //这个是发送信息至服务器时内容编码类型
            dataType: "json",
            success: function (data) {
                console.log(JSON.stringify(data));
                if (data.statue == true) {
                    carquery();
                    alert("新增成功！")
                } else {
                    alert(data.msg)
                }

            }
        })
    });

    //用户详情关闭按钮
    $(".closeInfoBtn").click(function () {
        $(".userInfo_show").fadeOut();
    });

    //菜单切换
    $(".ownerInfo").click(function () {
        $(".add_Inp_box").fadeOut();
        $(".ownerInfo_table").fadeIn().siblings(".info_Table").fadeOut();
    });
    $(".staff_manage").click(function () {
        $(".add_Inp_box").fadeOut();
        $(".staff_manage_table").fadeIn().siblings(".info_Table").fadeOut();
    });
    $(".park_manage").click(function () {
        $(".add_Inp_box").fadeOut();
        $(".parkInfo_table").fadeIn().siblings(".info_Table").fadeOut();
    });
    $(".equipment_manage").click(function () {
        $(".add_Inp_box").fadeOut();
        $(".equipment_table").fadeIn().siblings(".info_Table").fadeOut();
    });
    $(".complain_manage").click(function () {
        $(".add_Inp_box").fadeOut();
        $(".complain_table").fadeIn().siblings(".info_Table").fadeOut();
    });
    $(".repair_manage").click(function () {
        $(".add_Inp_box").fadeOut();
        $(".repair_table").fadeIn().siblings(".info_Table").fadeOut();
    })

    //详情更新
    /* $(".updataInfoBtn").click(function () {
     var userStop1 = {userName:"12345",userState:"1"};
     var userStop = JSON.stringify(userStop1);
     $.ajax({
     type: "post",
     url:  prefix +"user/updateUser",
     data: userStop,
     contentType: "application/json;charset=utf-8", //这个是发送信息至服务器时内容编码类型
     dataType:"json",
     success:function () {
     alert("更新成功！")
     },
     error:function () {
     alert("操作失败,请稍后再试！")
     }
     })
     })*/
});